package org.black.phoneUtility.sms.reply.app.fragment;

import org.black.phoneUtility.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class SmsReplyResponseNumberAddNumberDialogFragment extends
		DialogFragment {
	public static final String TAG = SmsReplyResponseNumberAddNumberDialogFragment.class
			.getName();

	public interface SmsReplyResponseNumberAddNumberInterface {
		public void onChooseResponseNumberFromAllNumbers();

		public void onChooseResponseNumberFromAllNumbersInMyContacts();

		public void onChooseResponseNumberFromAllNumbersNotInMyContacts();

		public void onChooseResponseNumberFromChooseFromMyContacts();

		public void onChooseResponseNumberFromUserInput();

		public void onChooseResponseNumberFromSmsMessagesContainKeyword();

		public void onChooseResponseNumberFromNumbersFromContactGroup();
	}

	private SmsReplyResponseNumberAddNumberInterface smsReplyResponseNumberAddNumberInterface;

	@Override
	public void onActivityCreated(Bundle arg0) {
		super.onActivityCreated(arg0);
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			smsReplyResponseNumberAddNumberInterface = (SmsReplyResponseNumberAddNumberInterface) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(
					activity.toString()
							+ " must implement SmsReplyResponseNumberAddNumberInterface");
		}
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		super.onCreateDialog(savedInstanceState);
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
		builder.setItems(R.array.sms_response_number_from_add_number_from,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						switch (which) {
						case 0:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromAllNumbers();
							break;
						case 1:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromAllNumbersInMyContacts();
							break;
						case 2:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromAllNumbersNotInMyContacts();
							break;
						case 3:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromChooseFromMyContacts();
							break;
						case 4:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromUserInput();
							break;
						case 5:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromSmsMessagesContainKeyword();
							break;
						case 6:
							smsReplyResponseNumberAddNumberInterface
									.onChooseResponseNumberFromNumbersFromContactGroup();
							break;
						default:
							break;
						}
					}
				});
		return builder.create();
	}

	@Override
	public void onDestroyView() {
		super.onDestroyView();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		smsReplyResponseNumberAddNumberInterface = null;
	}

}
